package com.kc.web.controller.business;

import com.kc.business.domain.BizUserFeedBack;
import com.kc.business.service.IBizUserFeedBackService;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * TODO
 * 用户反馈
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/11/11
 */
@RestController
@RequestMapping("/business/userFeedback")
public class BizKcUserFeedBackController extends BaseController {
    @Autowired
    private IBizUserFeedBackService userFeedBackService;

    /**
     * 用户反馈列表
     *
     * @param bizUserFeedBack
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:userFeedback:list')")
    @GetMapping("/list")
    public TableDataInfo getList(BizUserFeedBack bizUserFeedBack) {
        startPage();
        List<BizUserFeedBack> userFeedBackList = userFeedBackService.getList(bizUserFeedBack).stream().map(feedback -> {
            if (StringUtils.isNotBlank(feedback.getImages())) {
                //字符串转数组
                feedback.setImagesList(StringUtils.split(feedback.getImages(), ","));
            }
            return feedback;
        }).collect(Collectors.toList());
        return getDataTable(userFeedBackList);
    }
}
